//
//  YYT_ChannelView.m
//  AudioVisualFeast
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YYT_ChannelView.h"
#import "YYT_ChannelCollectionViewCell.h"

@interface YYT_ChannelView ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation YYT_ChannelView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self kongjian];
    }
    return self;
}

- (void)kongjian{
    UICollectionViewFlowLayout *flowLauout = [[UICollectionViewFlowLayout alloc]init];
    self.dingyue = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64) collectionViewLayout:flowLauout];
    self.dingyue.dataSource = self;
    self.dingyue.delegate = self;
    [self.dingyue registerClass:[YYT_ChannelCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    flowLauout.itemSize = CGSizeMake(187, 160);
    flowLauout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    flowLauout.minimumInteritemSpacing = 1;
    flowLauout.minimumLineSpacing = 1;
    flowLauout.scrollDirection = UICollectionViewScrollDirectionVertical;
    [self addSubview:self.dingyue];
    [self.dingyue registerClass:[YYT_ChannelCollectionViewCell class] forCellWithReuseIdentifier:@"CustomViewIdentifier"];
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    YYT_ChannelCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CustomViewIdentifier" forIndexPath:indexPath];
    cell.channel = [self.chArray objectAtIndex:indexPath.row];
    return cell;
    
    return nil;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _chArray.count;
}

// 音悦V榜 73
// V榜特别企划 94
// 粉丝聚焦 91
// 热门推荐 25
// Stage 36
// 震撼史乐 86
// 时光机 89
// 周榜 92
// 音悦人 8
// 劲歌金曲 58


// 音悦大来宾 10
// 爱逗秀 11
// STAR!调查团 9

// 疯狂恶搞 84
// 东瀛 16
// 韩流 15
// 欧美 19
// 港台 18
// 动漫 44
// 影视原声 65
// 内地 17
// 饭制 13
// 二次元 12
// 综艺乐翻天 53
// 现场 20
// 性感 11
// 萌宠 29

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.item == 0)
    {
        [self.channelDelegate qiao1:@"音悦V榜" shu1:73];
    }
    else if (indexPath.item == 2)
    {
        [self.channelDelegate qiao1:@"V榜特别企划" shu1:94];
    }
    else if (indexPath.item == 5)
    {
        [self.channelDelegate qiao1:@"粉丝聚焦" shu1:91];
    }
    else if (indexPath.item == 7)
    {
        [self.channelDelegate qiao1:@"热门推荐" shu1:25];
    }
    else if (indexPath.item == 8)
    {
        [self.channelDelegate qiao1:@"Stage" shu1:36];
    }
    else if (indexPath.item == 14)
    {
        [self.channelDelegate qiao1:@"震撼史乐" shu1:86];
    }
    else if (indexPath.item == 16)
    {
        [self.channelDelegate qiao1:@"时光机" shu1:89];
    }
    else if (indexPath.item == 17)
    {
        [self.channelDelegate qiao1:@"周榜2015" shu1:92];
    }
    else if (indexPath.item == 21)
    {
        [self.channelDelegate qiao1:@"音悦人" shu1:8];
    }
    else if (indexPath.item == 26)
    {
        [self.channelDelegate qiao1:@"劲歌金曲" shu1:58];
    }
    else if (indexPath.item == 1)
    {
        [self.channelDelegate qiao2:@"音乐大来宾" shu2:10];
    }
    else if (indexPath.item == 27)
    {
        [self.channelDelegate qiao2:@"爱逗秀" shu2:11];
    }
    else if (indexPath.item == 3)
    {
        [self.channelDelegate qiao2:@"STAR!调查团" shu2:9];
    }
    else if (indexPath.item == 4)
    {
        [self.channelDelegate qiao1:@"疯狂恶搞" shu1:84];
    }
    else if (indexPath.item == 6)
    {
        [self.channelDelegate qiao1:@"东瀛" shu1:16];
    }
    else if (indexPath.row == 9)
    {
        [self.channelDelegate qiao1:@"韩流" shu1:15];
    }
    else if (indexPath.item == 10)
    {
        [self.channelDelegate qiao1:@"欧美" shu1:19];
    }
    else if (indexPath.item == 11)
    {
        [self.channelDelegate qiao1:@"港台" shu1:18];
    }
    else if (indexPath.item == 12)
    {
        [self.channelDelegate qiao1:@"动漫" shu1:44];
    }
    else if (indexPath.item == 13)
    {
        [self.channelDelegate qiao1:@"影视原声" shu1:65];
    }
    else if (indexPath.item == 15)
    {
        [self.channelDelegate qiao1:@"内地" shu1:17];
    }
    else if (indexPath.item == 18)
    {
        [self.channelDelegate qiao1:@"饭制" shu1:13];
    }
    else if (indexPath.item == 19)
    {
        [self.channelDelegate qiao1:@"二次元" shu1:12];
    }
    else if (indexPath.item == 20)
    {
        [self.channelDelegate qiao1:@"综艺乐翻天" shu1:53];
    }
    else if (indexPath.item == 22)
    {
        [self.channelDelegate qiao1:@"现场" shu1:20];
    }
    else if (indexPath.item == 23)
    {
        [self.channelDelegate qiao1:@"性感" shu1:11];
    }
    else if (indexPath.item == 24)
    {
        [self.channelDelegate qiao1:@"热舞" shu1:10];
    }
    else if (indexPath.item == 25)
    {
        [self.channelDelegate qiao1:@"萌宠" shu1:29];
    }
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
